/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.yunhoo.sys.listener;

import javax.faces.event.PhaseEvent;
import javax.faces.event.PhaseId;
import javax.faces.event.PhaseListener;

/**
 *
 * @author shellcc
 */
public class MyPhaseListener implements PhaseListener {

    @Override
    public void afterPhase(PhaseEvent pe) {
        //System.out.println(" ************ after " + pe.getPhaseId());
    }

    @Override
    public void beforePhase(PhaseEvent pe) {
        //System.out.println(" ************ before " + pe.getPhaseId());
        
        /*
        FacesContext fc = pe.getFacesContext();
        ExternalContext extContext = fc.getExternalContext();
        HttpSession session = (HttpSession) extContext.getSession(false);

        HashMap<String, Object> sysParam = (HashMap<String, Object>) session.getAttribute("sysParam");
        if (sysParam == null) {
            System.out.println("sysParam : " + sysParam);
            return;
        }
        Integer isRepeat = (Integer) sysParam.get("loginRepeat");

        if (isRepeat == 1) {
            System.out.println("session is repeat : " + isRepeat);
            
            System.out.println(" 获取 response !");

            fc.getApplication().getNavigationHandler().handleNavigation(fc, null, "/login.xhtml");

            System.out.println("跳转 ~~~~~~~~~~");
        }
        */
    }

    @Override
    public PhaseId getPhaseId() {
        return PhaseId.RESTORE_VIEW;
    }
}
